﻿using System;
using RayDen.Library.Core;
using RayDen.Library.Core.Primitives;

namespace RayDen.Engines.Ethalon.Entity
{
    public class RayDifferential : RayInfo
    {
        internal bool hasDifferentials;
        internal Point rxOrigin, ryOrigin;
        internal Vector rxDirection, ryDirection;
        internal float time;
        internal int depth;

        [Obsolete]
        public RayDifferential(Point org, Vector dir, float t0 = 0.0001f, float t1 = 10000f)
            : base(org, dir, t0, t1)
        {
            hasDifferentials = false;
            time = 0f;
            depth = 0;

        }
        public RayDifferential(ref Point org, ref Vector dir, float t0 = 0.0001f, float t1 = 10000f)
        {
            this.Org = org;
            this.Dir = dir;
            this.MinT = t0;
            this.MaxT = t1;
            InvDir = 1f / dir;
            hasDifferentials = false;

        }
        public RayDifferential(RayInfo vray)
            : base(vray)
        {
            hasDifferentials = false;
        }

        public void ScaleDifferentials(float s)
        {
            rxOrigin    = Org + (rxOrigin - Org) * s;
            ryOrigin    = Org + (ryOrigin - Org) * s;
            rxDirection = Dir + (rxDirection - Dir) * s;
            ryDirection = Dir + (ryDirection - Dir) * s;
        } 
    }
}